package com.joseph.websocket.test;

import com.google.common.util.concurrent.Uninterruptibles;
import sun.awt.windows.ThemeReader;
import sun.misc.Unsafe;

import java.lang.reflect.Field;
import java.util.concurrent.*;

public class JOL1 {

    private String a;

    public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException, InstantiationException, ClassNotFoundException {

        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(0, 1,
                60L, TimeUnit.SECONDS,
                new SynchronousQueue<Runnable>(), new RejectedExecutionHandler() {

            @Override
            public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
                System.out.println(1);
            }
        });

        for (int i = 0; i < 3; i++) {
            threadPoolExecutor.execute(new Runnable() {
                @Override
                public void run() {
                    Uninterruptibles.sleepUninterruptibly(10, TimeUnit.SECONDS);
                }
            });
        }
    }
}
